<template>
  <div class="movie_body" ref="movieBody">
    <div class="loading-container" v-show="!comingList.length">
      <loading></loading>
    </div>
    <ul class="content">
      <li v-for="item in comingList" :key="item.id">
        <div class="pic_show">
          <img :src="item.img | setWH('128.180')" @click="hanedlToDetail(item.id)" />
        </div>
        <div class="info_list">
          <h2 @click="hanedlToDetail(item.id)">
            {{item.nm}}
            <img v-if="item.version" src="../../assets/maxs.png" alt />
          </h2>
          <p>
            <span class="person">{{item.wish}}</span> 人想看
          </p>
          <p>主演: {{item.star}}</p>
          <p>{{item.rt}}上映</p>
        </div>
        <div class="btn_pre">预售</div>
      </li>
    </ul>
  </div>
</template>

<script>
import BScroll from "better-scroll";
import Scroll from "../scroll/scroll";
import loading from "../loading/loading";
export default {
  name: "comingSoon",
  data() {
    return {
      comingList: [],
      prevityId: -1
    };
  },
  components: {
    Scroll,
    loading
  },
  activated() {
    const cityId = this.$store.state.city.id;
    if (this.prevityId === cityId) {
      return;
    }
    this.axios.get("/api/movieComingList?cityId=" + cityId).then(res => {
      const msg = res.data.msg;
      if (msg === "ok") {
        this.comingList = res.data.data.comingList;
        this.prevityId = cityId;
        //console.log(this.comingList)
        // this.$nextTick(() => {
        //   if (!this.scroll) {
        //     this.scroll = new BScroll(this.$refs.movieBody, {});
        //     console.log(this.scroll)
        //   }
        // });
      }
    });
  },
  methods: {
    hanedlToDetail(movieId) {
      this.$router.push("/movie/detail/2/" + movieId);
    }
  }
};
</script>

<style scoped>
.movie_body {
  flex: 1;
  overflow: auto;
}
.content {
  /* height: 1300px; */
}
.movie_body ul {
  /* height: 90%; */
  margin: 0 12px;
  overflow: hidden;
}
.movie_body ul li {
  margin-top: 12px;
  display: flex;
  align-items: center;
  border-bottom: 1px #e6e6e6 solid;
  padding-bottom: 10px;
}
.movie_body .pic_show {
  width: 64px;
  height: 90px;
}
.movie_body .pic_show img {
  width: 100%;
}
.movie_body .info_list {
  margin-left: 10px;
  flex: 1;
  position: relative;
}
.movie_body .info_list h2 {
  font-size: 17px;
  line-height: 24px;
  width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.movie_body .info_list p {
  font-size: 13px;
  color: #666;
  line-height: 22px;
  width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.movie_body .info_list .grade {
  font-weight: 700;
  color: #faaf00;
  font-size: 15px;
}
.movie_body .info_list img {
  width: 50px;
  position: absolute;
  right: 10px;
  top: 5px;
}
.movie_body .btn_mall,
.movie_body .btn_pre {
  width: 47px;
  height: 27px;
  line-height: 28px;
  text-align: center;
  background-color: #f03d37;
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.movie_body .btn_pre {
  background-color: #3c9fe6;
}
.loading-container {
  position: absolute;
  width: 100%;
  top: 50%;
  transform: translateY(-50%);
}
</style>